package com.guan.study.easyExcelDemo.utils;


import com.alibaba.excel.metadata.Head;
import com.alibaba.excel.write.handler.CellWriteHandler;
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
import com.alibaba.excel.write.metadata.holder.WriteTableHolder;
import org.apache.poi.ss.usermodel.*;

public class ImageWriteHandler implements CellWriteHandler {

    @Override
    public void beforeCellCreate(WriteSheetHolder writeSheetHolder,
                                 WriteTableHolder writeTableHolder,
                                 Row row, Head head, Integer columnIndex,
                                 Integer relativeRowIndex, Boolean isHead) {


        Sheet sheet = writeSheetHolder.getSheet();
        Workbook workbook = sheet.getWorkbook();
        Drawing<?> drawingPatriarch = sheet.createDrawingPatriarch();

    }

//    private List<RowImageData> getRowImageDataList(WriteSheetHolder writeSheetHolder) {
//        // 返回要插入图片的行号和对应的图片路径列表，这里根据实际情况自行定义
//        // 可以根据行号从图片URL中获取图片并保存到本地，然后返回行号和本地图片路径的映射关系
//        List<RowImageData> rowImageDataList = new ArrayList<>();
//
//        for (int i = writeSheetHolder.getSheetNo(); i < writeSheetHolder.getSheetNo() + writeSheetHolder.getSheet().getLastRowNum(); i++) {
//            String imagePath = "图片路径"; // 这里替换为您真正的图片路径
//            rowImageDataList.add(new RowImageData(i, imagePath));
//        }
//
//        return rowImageDataList;
//    }
}
